<?php
namespace Modules\Taxonomy\Controllers;

use Core\Mvc\Controller;
use Modules\Search\Library\Search;

class IndexController extends Controller
{

    public function tagsSourceAction($taxonomy)
    {
        self::$variables['#templates'] = 'json';

        $term = $this->request->getQuery('term');
        $term = urldecode($term);

        $data = [];
        $search = new Search(WEB_CODE . '_term');
        $searchData = $search->search([
            'conditions' => $term,
            'limit' => [20, 0]
        ]);

        foreach ($searchData as $item){
            $data[] = $item->name;
        }

        self::$variables['data'] = $data;
    }
}
